package person.mybatisplusstudy.mapper;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;
import person.mybatisplusstudy.po.Book;
import person.mybatisplusstudy.po.UserBookVO;

import java.util.List;

/**
 * @author 林志鹏
 * @version 1.0.0
 * @date 2021/5/2 22:58
 */
@Mapper
@Repository
public interface BookMapper extends BaseMapper<Book> {

    @Select("select k.*,u.name as user_name from page_book k left join page_user u on k.user_id = u.id"
            + " ${ew.customSqlSegment}")
    List<UserBookVO> getBookAndUser(Page<UserBookVO> page, @Param(Constants.WRAPPER) QueryWrapper<UserBookVO> queryWrapper);
}
